/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager;

import br.com.deployment.entidade.registroimovel.Imovel;
import br.com.deployment.servico.ImovelServico;
import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.annotation.PostConstruct;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author roniere
 */
@ManagedBean
@SessionScoped
public class ManagerIndex implements  Serializable{
    
    @EJB
    ImovelServico imovelDao;
    
    private List<Imovel> lstimovel;
    private List<String[]> breadcrumb;
    private String[] aux;

    public ManagerIndex() {
    }
    
    @PostConstruct
    public void init(){
        breadcrumb = new ArrayList<String[]>();
        aux = new String[2];
        addDefault();
    }
    
    public void reinitArray(){
        aux = new String[2];
    }
    
    public  void addLink(String prm, String url){
        aux[0] = prm;
        aux[1] = url;
        breadcrumb.add(aux);
        reinitArray();
    }
    public  void addDefault(){
        aux[0] = "Principal";
        aux[1] = "#";
        breadcrumb.add(aux);
        reinitArray();
    }
    public void none(){
        breadcrumb.clear();
    }

    public String[] getAux() {
        return aux;
    }

    public void setAux(String[] aux) {
        this.aux = aux;
    }

    public List<String[]> getBreadcrumb() {
        return breadcrumb;
    }

    public void setBreadcrumb(List<String[]> breadcrumb) {
        this.breadcrumb = breadcrumb;
    }
    
    
    public List<Imovel> getLstimovel() {
//        lstimovel = imovelDao.findAll();
        return lstimovel;
    }

    public void setLstimovel(List<Imovel> lstimovel) {
        this.lstimovel = lstimovel;
    }

    public void redirect(String string) {
        try {
            FacesContext context = FacesContext.getCurrentInstance();
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerIndex.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
 
    
    
    
}
